﻿#ifndef _GEOMETRY_IENVELOPE_H
#define _GEOMETRY_IENVELOPE_H

#include "kernel/dll_cfg.h"
#include "kernel/OgrePlatform.h"
#include "kernel/Referenced.h"

namespace FD
{
	namespace Kernel
	{
		namespace Geometry
		{
			namespace Interface
			{
				/// <summary>
				/// 维度类型
				/// </summary>
				enum DimensionType
				{
					/// <summary>
					/// 未知维度
					/// </summary>
					DT_DIMENSION_UNKNOWN,
					/// <summary>
					/// 0维度
					/// </summary>
					DT_DIMENSION_0,
					/// <summary>
					/// 1维度
					/// </summary>
					DT_DIMENSION_1,
					/// <summary>
					/// 2维度
					/// </summary>
					DT_DIMENSION_2,
					/// <summary>
					/// 2.5维度
					/// </summary>
					DT_DIMENSION_2_5,
					/// <summary>
					/// 3维度
					/// </summary>
					DT_DIMENSION_3,
				};

				/// <summary>
				/// 包围盒类接口，定义了如何获取和设置包围盒，以及
				/// 包围盒相关计算。
				/// </summary>
				class /*interface-only*/ IEnvelope : public FD::Kernel::CReferenced
				{
				public:
					/// <summary>
					/// 默认析构函数
					/// </summary>
					virtual ~IEnvelope() {};

				public:
					/// <summary>
					/// 获取包围盒在X轴上最小值
					/// </summary>
					/// <param name=""></param>
					/// <returns>包围盒在X轴上最小值</returns>
					virtual double getMinX() const { return 0.0; };
					/// <summary>
					/// 获取包围盒在X轴上最大值
					/// </summary>
					/// <param name=""></param>
					/// <returns>包围盒在X轴上最大值</returns>
					virtual double getMaxX() const { return 0.0; };
					/// <summary>
					/// 获取包围盒在Y轴上最小值
					/// </summary>
					/// <param name=""></param>
					/// <returns>包围盒在Y轴上最小值</returns>
					virtual double getMinY() const { return 0.0; };
					/// <summary>
					/// 获取包围盒在Y轴上最大值
					/// </summary>
					/// <param name=""></param>
					/// <returns>包围盒在Y轴上最大值</returns>					
					virtual double getMaxY() const { return 0.0; };
					/// <summary>
					/// 获取包围盒在Z轴上最小值
					/// </summary>
					/// <param name=""></param>
					/// <returns>包围盒在Z轴上最小值</returns>
					virtual double getMinZ() const { return 0.0; };
					/// <summary>
					/// 获取包围盒在Z轴上最大值
					/// </summary>
					/// <param name=""></param>
					/// <returns>包围盒在Z轴上最大值</returns>
					virtual double getMaxZ() const { return 0.0; };
					/// <summary>
					/// 获取包围盒宽度，该宽度是X轴上间距
					/// </summary>
					/// <param name=""></param>
					/// <returns>包围盒宽度</returns>
					virtual double getWidth() const { return 0.0; };
					/// <summary>
					/// 获取包围盒高度，该宽度是Y轴上间距
					/// </summary>
					/// <param name=""></param>
					/// <returns>包围盒高度</returns>
					virtual double getHeight() const { return 0.0; };
					/// <summary>
					/// 获取包围盒深度，该宽度是Z轴上间距
					/// </summary>
					/// <param name=""></param>
					/// <returns>包围盒深度</returns>
					virtual double getDepth() const { return 0.0; };
					/// <summary>
					/// 判断是否是3维Box
					/// </summary>
					/// <param name=""></param>
					/// <returns>是，返回true，否则，返回false</returns>
					virtual bool isBox() const { return false; };
					/// <summary>
					/// 判断包围盒对象是否有效。
					/// 有效条件是 1.最大值不小于最小值
					///           2.宽度和高度必须为正
					/// </summary>
					/// <param name=""></param>
					/// <returns>有效，返回true，否则，返回false</returns>
					virtual bool isValid() const { return false; };
					/// <summary>
					/// 深度拷贝
					/// </summary>
					/// <param name=""></param>
					/// <returns>包围盒对象</returns>
					virtual IEnvelope* clone() const { return NULL; };
					/// <summary>
					/// 设置包围盒在X轴上最小值
					/// </summary>
					/// <param name="value">包围盒在X轴上最小值</param>
					/// <returns></returns>
					virtual void setMinX( double value) {};
					/// <summary>
					/// 设置包围盒在X轴上最大值
					/// </summary>
					/// <param name="value">包围盒在X轴上最大值</param>
					/// <returns></returns>
					virtual void setMaxX( double value) {};
					/// <summary>
					/// 设置包围盒在Y轴上最小值
					/// </summary>
					/// <param name="value">包围盒在Y轴上最小值</param>
					/// <returns></returns>
					virtual void setMinY( double value) {};
					/// <summary>
					/// 设置包围盒在Y轴上最大值
					/// </summary>
					/// <param name="value">包围盒在Y轴上最大值</param>
					/// <returns></returns>
					virtual void setMaxY( double value) {};
					/// <summary>
					/// 设置包围盒在Z轴上最小值
					/// </summary>
					/// <param name="value">包围盒在Z轴上最小值</param>
					/// <returns></returns>
					virtual void setMinZ( double value) {};
					/// <summary>
					/// 设置包围盒在Z轴上最大值
					/// </summary>
					/// <param name="value">包围盒在Z轴上最大值</param>
					/// <returns></returns>
					virtual void setMaxZ( double value) {};
					/// <summary>
					/// 判断是否包含指定坐标点
					/// </summary>
					/// <param name="x">X值</param>
					/// <param name="y">Y值</param>
					/// <param name="z">Z值</param>
					/// <returns></returns>
					virtual bool containsCoordinate(double x,double y,double z,FD::Kernel::Geometry::Interface::DimensionType type) const { return false; };
					/// <summary>
					/// 判断是否包含指定包围盒
					/// </summary>
					/// <param name="envelope">指定包围盒</param>
					/// <param name="type">指定维度</param>
					/// <returns>包含，返回true;否则，返回false</returns>
					virtual bool containsEnvelope(const IEnvelope & envelope,FD::Kernel::Geometry::Interface::DimensionType type) const { return false; };
					/// <summary>
					/// 判断指定包围盒是否相交
					/// </summary>
					/// <param name="envelope">指定包围盒</param>
					/// <param name="type">指定维度</param>
					/// <returns>相交，返回true;否则，返回false</returns>
					virtual bool isIntersects(const IEnvelope & envelope,FD::Kernel::Geometry::Interface::DimensionType type) const { return false; };
					/// <summary>
					/// 缩放包围盒
					/// </summary>
					/// <param name="isRadio">是否按比例处理</param>
					/// <param name="scaleX">如果isRadio = true,范围[0,~];否则，scaleX按照实际距离缩放，[-~，~]</param>
					/// <param name="scaleY">如果isRadio = true,范围[0,~];否则，scaleY按照实际距离缩放，[-~，~]</param>
					/// <param name="scaleZ">如果isRadio = true,范围[0,~];否则，scaleZ按照实际距离缩放，[-~，~]</param>
					/// <returns></returns>
					virtual void expands(bool isRadio,double scaleX,double scaleY,double scaleZ) {};
					/// <summary>
					/// 包围盒合并
					/// </summary>
					/// <param name="envelope">指定包围盒</param>
					/// <param name="type">指定维度</param>
					/// <returns></returns>
					virtual void unions(const IEnvelope & envelope,FD::Kernel::Geometry::Interface::DimensionType type) {};
					/// <summary>
					/// 包围盒求交
					/// </summary>
					/// <param name="envelope">指定包围盒</param>
					/// <param name="type">指定维度</param>
					/// <returns></returns>
					virtual void intersects(const IEnvelope & envelope,FD::Kernel::Geometry::Interface::DimensionType type) {};
					/// <summary>
					/// 判断指定包围盒是否相等
					/// </summary>
					/// <param name="envelope">指定包围盒</param>
					/// <param name="tolerance">容差范围</param>
					/// <param name="type">指定维度</param>
					/// <returns>true，相等；false，不相等</returns>
					virtual bool equals(const IEnvelope& envelope,double tolerance,FD::Kernel::Geometry::Interface::DimensionType type) const { return false; };
				protected:
					/// <summary>
					/// 默认构造函数
					/// </summary>
					IEnvelope() {};
				};
			}
		}
	}
}

#endif
